package com.wanbangee.marksystem.service.imp;

import java.text.DateFormat;
import java.util.Date;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.wanbangee.marksystem.dao.MAnswerSheetRecordDao;
import com.wanbangee.marksystem.dao.MExamMarkerDao;
import com.wanbangee.marksystem.entities.MAnswerSheetRecord;
import com.wanbangee.marksystem.service.ISpecialTestService;

@Service
public class SpecialTestServiceImpl implements ISpecialTestService {
	
	@Autowired
	private MExamMarkerDao examMarkerDao;
	@Autowired
	private MAnswerSheetRecordDao answerSheetRecordDao;
	
	/**
	 * 查询出指定特殊卷信息，用于插入答题记录表 
	 * @param examId
	 * @param examSubId
	 * @param markerId
	 * @param scoreId
	 * @return
	 */
	@Override
	public MAnswerSheetRecord specialTestInfo(Integer examId, Integer examSubId, Integer markerId, Integer scoreId,
			Integer addUserId, String addNm) {
		MAnswerSheetRecord sheet = this.examMarkerDao.selectAnswerSheetRecordInfo(examId, examSubId, markerId, scoreId);
		sheet.setAddNm(addNm);//添加人名字
		sheet.setAddUserId(Long.valueOf(addUserId));//添加人id
		sheet.setAddTime(DateFormat.getDateTimeInstance().format(new Date()));//添加时间
		System.out.println("setting+specialTestInfo:"+sheet);
		return sheet;
	}

	/**
	 * 新增新的特殊卷
	 * @param sheet 特殊卷
	 * @param recordId 记录类型(1,问题卷，2，优秀卷，3，典型错误卷,4已处理问题卷)
	 * @return
	 */
	@Override
	public Boolean addSpecialTest(MAnswerSheetRecord sheet,Long recordId) {
		sheet.setRecordType(recordId);
		System.out.println(sheet.getSubId()+"--------");
		System.out.println("setting+addSpecialTest:"+sheet);
		return this.answerSheetRecordDao.insetAnswerSheetRecord(sheet)!=0;
	}



}
